package common

import (
	"strings"
	"time"
)

func SplitString(str string, sep string, strip bool) []string {
	var result []string
	for {
		m := strings.IndexAny(str, sep)
		if m < 0 {
			if !strip || len(str) > 0 {
				result = append(result, str)
			}
			break
		}
		if m == 0 {
			if !strip {
				result = append(result, "")
			}
		} else {
			result = append(result, str[0:m])
		}
		str = str[m+1:]
	}
	return result
}

func FormatTime(now uint32) string {
	return time.Unix(int64(now), 0).Format("2006-01-02 15:04:05")
}
